package com.qf.controller.business;

import com.qf.entitys.RespBean;
import com.qf.entitys.UrbanAreas;
import com.qf.service.UrbanAreasService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/city")
public class CityController {
    @Resource
    private UrbanAreasService service;
    @GetMapping("/querycity")
    @ResponseBody
    public RespBean querycity(String id){
        List<UrbanAreas> urbanAreas = service.selectByCity(id.substring(0, 2));
        return RespBean.success(0,"加载成功",urbanAreas);
    }

    @GetMapping("/queryarea")
    @ResponseBody
    public RespBean queryarea(String citycode){
        System.out.println("citycode:");
        System.out.println(citycode);
        List<UrbanAreas> urbanAreas = service.selectByArea(citycode);
        return RespBean.success(0,"加载成功",urbanAreas);
    }
}
